﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using System.Diagnostics;

namespace EyesOnTrain
{
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            InitializeTraceListener();

            Trace.WriteLine("Application Start", "Normal");

            try
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);

                Application.Run(new MainForm());
            }
            catch (Exception exp)
            {
                do
                {
                    Trace.TraceError(DateTime.Now + ": " + exp.Message);
                    Trace.TraceInformation(DateTime.Now + ": " + exp.Source + ":" + exp.StackTrace);

                    exp = exp.InnerException;
                } while (exp != null);

                throw;
            }
            finally
            {
                Trace.Flush();
            }
        }

        private static void InitializeTraceListener()
        {
            DefaultTraceListener traceListner = new DefaultTraceListener();
            traceListner.LogFileName = "EyesOnTrain.log";
            Trace.Listeners.Add(traceListner);
        }
    }
}
